package com.spring.boot.aopanno;

import net.sf.jsqlparser.statement.select.Join;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

// 增强类
@Component
@Aspect
public class UserProxy {

//    final String EEDT = "execution(* com.spring.boot.aopanno.UserAop.add(..))";

    @Pointcut(value = "execution(* com.spring.boot.aopanno.UserAop.add(..))")
    public void pointCut(){

    }

    @Before(value = "pointCut() && args(id)")
    public void before(int id){

        System.out.println("代理.."+id);
        id ++;
        System.out.println("代理.."+id);
        System.out.println("before...");
    }

    // 后置通知，有异常后不执行
    @AfterReturning(value = "execution(* com.spring.boot.aopanno.UserAop.add(..))")
    public void afterReturn(){
        System.out.println("afterReturn...");
    }

    // 最终通知，无论是否有异常，都会执行
    @After(value = "execution(* com.spring.boot.aopanno.UserAop.add(..))")
    public void after(){
        System.out.println("after...");
    }


    // 异常通知
    @AfterThrowing(value = "execution(* com.spring.boot.aopanno.UserAop.add(..))")
    public String afterThrowing(){

        System.out.println("afterThrowing...");
        return "xxxxxxxxxxxxxxxxx";
    }


}
